package featuremodel.method;

import java.util.Vector;

import featuremodel.FeatureRep;

import skyblue.Method;
import skyblue.SkyBlueDef;
import skyblue.Variable;

public class AlternativeMethodNone extends Method {

	private Variable parent;
	private Vector<Variable> children;

	public AlternativeMethodNone(Variable parent, Vector<Variable> children) {

		this.parent = parent;
		this.children = children;

		getOutputs().add(parent);
		getOutputs().addAll(children);

	}

	public void setTobeMethodType() {

		parent.setTobemethodtype(SkyBlueDef.METHOD_TYPE_UNBIND);
		for (int i = 0; i < children.size(); i++) {
			children.get(i).setTobemethodtype(SkyBlueDef.METHOD_TYPE_UNBIND);
		}

	}
	public void clearTobeMethodType() {
		parent.setTobemethodtype(null);
		for (int i = 0; i < children.size(); i++) {
			children.get(i).setTobemethodtype(null);
		}
		
	}

	public void setTobeMethodType2() {

		parent.setTobeMethodType2(SkyBlueDef.METHOD_TYPE_UNBIND);
		for (int i = 0; i < children.size(); i++) {
			children.get(i).setTobeMethodType2(SkyBlueDef.METHOD_TYPE_UNBIND);
		}
	}

	public void clearTobeMethodType2() {
		parent.setTobeMethodType2(null);
		for (int i = 0; i < children.size(); i++) {
			children.get(i).setTobeMethodType2(null);
		}
	}

	public void execute() {

		FeatureRep fp = (FeatureRep) parent.getValue().getValuerep();
		fp.setBindState(SkyBlueDef.VARIABLE_UNBIND);
		parent.setMethodtype(SkyBlueDef.METHOD_TYPE_UNBIND);
		parent.setTobemethodtype(null);

		for (int i = 0; i < children.size(); i++) {
			fp = (FeatureRep) children.get(i).getValue().getValuerep();
			fp.setBindState(SkyBlueDef.VARIABLE_UNBIND);
			children.get(i).setMethodtype(SkyBlueDef.METHOD_TYPE_UNBIND);
			children.get(i).setTobemethodtype(null);
		}
	}

	public Variable getParent() {
		return parent;
	}

	public void setParent(Variable parent) {
		this.parent = parent;
	}

	public Vector<Variable> getChildren() {
		return children;
	}

	public void setChildren(Vector<Variable> children) {
		this.children = children;
	}

}
